using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace QuanLyHocPhi.Model.Mapping
{
    public class PhieuThuMap : EntityTypeConfiguration<PhieuThu>
    {
        public PhieuThuMap()
        {
            // Primary Key
            this.HasKey(t => t.MaPhieuThu);

            // Properties
            this.Property(t => t.MaPhieuThu)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.SoQuyen)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.SoPhieu)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.NoiDungThu)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.MaBienChe)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.MaNguoiThu)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("PhieuThu");
            this.Property(t => t.MaPhieuThu).HasColumnName("MaPhieuThu");
            this.Property(t => t.SoQuyen).HasColumnName("SoQuyen");
            this.Property(t => t.SoPhieu).HasColumnName("SoPhieu");
            this.Property(t => t.NoiDungThu).HasColumnName("NoiDungThu");
            this.Property(t => t.NgayThu).HasColumnName("NgayThu");
            this.Property(t => t.MaBienChe).HasColumnName("MaBienChe");
            this.Property(t => t.MaNguoiThu).HasColumnName("MaNguoiThu");
            this.Property(t => t.LaHocPhi).HasColumnName("LaHocPhi");
            this.Property(t => t.DaIn).HasColumnName("DaIn");
            this.Property(t => t.SoTien).HasColumnName("SoTien");
            this.Property(t => t.HinhThucNop).HasColumnName("HinhThucNop");
            // Relationships
            this.HasRequired(t => t.BienCheSinhVienVaoHocKy)
                .WithMany(t => t.PhieuThuList)
                .HasForeignKey(d => d.MaBienChe);
            this.HasRequired(t => t.NguoiSuDung)
                .WithMany(t => t.PhieuThuList)
                .HasForeignKey(d => d.MaNguoiThu);

        }
    }
}
